package com.shop2cn.iapi.agentproducts.service;

import com.google.common.reflect.TypeToken;
import com.shop2cn.iapi.agentproducts.parameter.SelectProductListDto;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

import java.util.List;

/**
*选货中心Call
*FreeMaker Template自动生成代码
*/
public class SelectionListCallV2 extends YmatouBaseCall{
	private static String opurl ="product/selectionList";

	public SelectionListCallV2() {
		super(EnvSetup.getSystemUrl("agentproducts"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	public List<SelectProductListDto> getProductList(){
		String sResults=getJsonObject().get("productList").getAsJsonArray().toString();
		List<SelectProductListDto> FreezeProductResultList=(List<SelectProductListDto>) FormatUtil.GSONToObject(sResults, new TypeToken<List<SelectProductListDto>>(){}.getType());
		return FreezeProductResultList;
	}
}